export{}
//泛型接口
interface CollectData<T> {
    getListData: (val:T) => T[]
}

let obj: CollectData<string>= {
    getListData(val){
        let arr = []
        arr.push(val)
        return arr
    }
}

let obj2: CollectData<number> = {
    getListData(val){
        let arr=[]
        arr.push(val)
        return arr
    }
}

console.log(obj.getListData('bbb')); //['bbb']
console.log(obj2.getListData(20)); //[20]

//泛型类
class Person<T> {
    uid:T
    constructor(uid:T){
        this.uid=uid
    }
    sayHi(val:T):T[]{
        let arr=[]
        arr.push(val)
        return arr
    }
}

let xm: Person<number> = new Person(20)
xm.sayHi(100)

let xg: Person<string> = new Person('10')
xg.sayHi('200')